package com.heima.feign.article;

import com.heima.article.dto.ArticleDto;
import com.heima.article.entity.ApAuthor;
import com.heima.common.dto.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient("leadnews-article")
public interface ArticleFeign {


    /**
     * 保存文章作者
     *
     * @param entity
     * @return
     */
    @PostMapping("/api/v1/author")
    public ResponseResult<ApAuthor> saveApAuthor(@RequestBody ApAuthor entity);


    /**
     * 发布正式文章
     *
     * @param dto 文章信息
     * @return
     */
    @PostMapping("/api/v1/article")
    public ResponseResult<Long> saveArticle(@RequestBody ArticleDto dto);


    /**
     * 根据作者id查询作者
     * @param id 作者ID
     * @return
     */
    @GetMapping("/api/v1/author/{id}")
    public ResponseResult<ApAuthor> getAuthorById(@PathVariable("id") Integer id);
}
